package com.hngy.xpq.androidintent;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onClick(View v){
        Intent intent = new Intent(Intent.ACTION_VIEW);
        switch (v.getId()){
            case R.id.button_email:
                intent.setData(Uri.parse("mailto:service@flag.com.tw"));
                intent.putExtra(Intent.EXTRA_CC,new String[] {"xpq@flag.com.tw"});
                intent.putExtra(Intent.EXTRA_SUBJECT,"您好");
                intent.putExtra(Intent.EXTRA_TEXT,"你是真np");
                break;
            case R.id.button_phone:
                intent.setAction(intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:110"));
                break;
        }
        startActivity(intent);
    }
}